<?php
/**
 *
 *
 *
 */
class Yz_Form_Renderer_Default
    extends Yz_Form_Renderer_Abstract
    implements Yz_Form_Renderer_Interface
{


    // ### subject to i18n ###
    protected $submitText = "OK";



    protected function renderElementDefault(
            Yz_Form_Element_Interface $element,
            Yz_Template_Interface $template)
    {
        $css = $element->exception ? ' yz-error' : "";
        $localizedName = $template->translate($element->name);
        $o = <<<html
            <div class="yz-form-element{$css}">
                <div class="yz-form-element-label"><span>{$localizedName}</span></div>\n
html;

        $o .= $element->render($template);
        $o .= <<<html
            </div>\n
html;
        return $o;
    }

    /**
     *
     *
     */
    protected function renderElementSubmit(Yz_Template_Interface $template)
    {
        $submitText = $template->translate($this->submitText);
        $o = <<<html
            <div class="yz-form-element yz-form-submit">
                <input type="submit" value="{$submitText}" />
            </div>\n
html;
        return $o;
    }



    /*
    protected function openFormHTML(Yz_Template_Interface $template)
    {
        $o = parent::openFormHTML($template);
        return $o;
    }
    */

    protected function closeFormHTML(Yz_Template_Interface $template)
    {
        $o = parent::closeFormHTML($template);
        $o = $this->renderElementSubmit($template) . $o ;
        return $o;
    }


}
